import fs from 'node:fs'
import path from 'node:path'
import * as process from 'node:process'
import { generate, gold, green, red } from '@ant-design/colors'

let colorVars = ''

const primaryColor = generate('#F5592C')
/**
 * 项目主色变量生成
 */
primaryColor.forEach((color, index) => {
  colorVars += `\t--jvyou-color-primary-${index + 1} : ${color};\n`
})

/**
 * 项目成功色变量生成
 */
colorVars += '\n'
green.forEach((color, index) => {
  colorVars += `\t--jvyou-color-success-${index + 1} : ${color};\n`
})

/**
 * 项目警告色变量生成
 */
colorVars += '\n'
gold.forEach((color, index) => {
  colorVars += `\t--jvyou-color-warning-${index + 1} : ${color};\n`
})

/**
 * 项目错误色变量生成
 */
colorVars += '\n'
red.forEach((color, index) => {
  colorVars += `\t--jvyou-color-error-${index + 1} : ${color};\n`
})

const cssFile = path.resolve(process.cwd(), './packages/jvyou-ui/src/style/theme/colors.less')

fs.writeFileSync(cssFile, `:root{\n${colorVars}\n}`)
